<?php

interface sp{
    public function getArea();
}
abstract class Shape
{
    public  function geArea(){}
}

class Circle extends Shape implements sp
{
    private $r;
    protected $s;
    public function __construct($r)
    {
        $this->r = $r;
    }

    public static function getPi()
    {
        return 3.14;
    }

    public function __clone()
    {
        $this->r = 2;
    }

    public function getArea()
    {
        $this->s = $this->r * $this->r * $this::getPi();
        return $this->s;
    }

    public function __set($name, $value)
    {
        if ($value < 0) {
            $value = 0;
        }
        $this->r = $value;
    }

    public function __get($name)
    {
        if ($name == "r")
            return $this->r;
    }

    public function __toString()
    {
        return "圆的半径：" . $this->r;
    }

    public function __call($name, $arguments)
    {
        echo "你的方法" . $name . "不存在";
        var_dump($arguments);
    }

    public function __sleep()
    {
        $d = ["r"];
        return $d;
    }
}

class  Rectangle extends Shape
{
    private $width, $height;

    public function __construct($w, $h)
    {
        $this->height = $h;
        $this->width = $w;
    }

    final public function geArea()
    {
        return $this->width * $this->height;
    }
}

final class Rect extends Rectangle
{
    public function __construct($width)
    {
        parent::__construct($width);
    }
}

trait test
{
    public function getArea()
    {

    }
}

$a = new Circle(12);
//$a->r=3;
//echo $a->getArea()."<br/>";
//echo Circle::getPi()."<br/>";
//
//$samlla=clone $a;
//echo $samlla->getArea()."<br/>";
//echo $a."<br/>";
//$a->getArea2("dsds");
$b = serialize($a);
echo "<br/>" . $b . "<br/>";
$c = unserialize($b);
var_dump($c);